from api.base import BaseRequest


class CircleLayer(BaseRequest):

    def save_api(self, account):
        url = 'https://api.admin.merchant.java.crmeb.net/api/admin/platform/circle/save'
        json_data = {
            'account': account,
            'address': '',
            'latitude': '',
            'longitude': '',
            'name': 'aaa',
            'phone': '13388889999',
            'range': '',
            'realName': account,
            'role': 1,
            'addressSwitch': 2,
            'pwd': '123456',
        }

        response = self.post(url, json_data)
        return response

    def delete_api(self, delete_id):
        url = f'https://api.admin.merchant.java.crmeb.net/api/admin/platform/circle/delete/{delete_id}'
        response = self.post(url)
        return response

    def select_api(self):
        url = 'https://api.admin.merchant.java.crmeb.net/api/admin/platform/circle/list/tree'
        response = self.get(url)
        return response


if __name__ == '__main__':
    circle_layer = CircleLayer()
    circle_layer.select_api()
    # account_data = "测试数据_" + Faker("zh_CN").name()
    # logger.info(f"测试数据:{account_data}")
    # save_id = circle_layer.save_api(account_data)['data']
    # data = circle_layer.select_api()
    # assert jmespath.search("data[?id==`{}`].realName".format(save_id), data) == account_data
